#include <iostream>
#include "../src/SenderXml.h"
#include "../src/ReceiverXml.h"
#include "ListenerPlug.h"
#include "ListenerRawPlug.h"
#include "../src/NetException.h"

using namespace net;
using namespace rapidxml;

int main(int argc, char* argv[]) {

	ListenerPlug listener;
	ListenerRawPlug listener_raw;
	ReceiverXml receiver;
	receiver.subscribe(&listener);
	try {
		std::cout << "Echo server" << std::endl;
		receiver.start(1234);

		ExtXml tx_xml;
		ExtXml rx_xml;

		xml_node<> *root = tx_xml.allocate_node(node_element, "Hello_world!");
		tx_xml.append_node(root);

		char c ;
		std::cin >> c;
		receiver.stop();

	} catch (NetException &e) {
		std::cout << "NetException: " << e.what() << std::endl;
	}

}
